#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#define INF 0x3f3f3f3f
using namespace std;
int main(){
	int n,x,y,good = -1,bad = -1;
	cin >> n;
	string name,winner,loser;
	for(int i = 0;i < n;i++){
		cin >> name >> x >> y;
		if(good!=-1){
			if(x*x+y*y<good){
				winner = name;
				good = x*x+y*y;
			} 
			else if(x*x+y*y>bad){
				loser = name;
				bad = x*x+y*y;
			}
		}
		else{
			winner = loser = name;
			good = bad = x*x+y*y;
		}
	}
	cout << winner << " " << loser;
	return 0;
}
